//
//  GMMyClassCell.m
//  Teecloud
//
//  Created by 小熊 on 2018/10/23.
//  Copyright © 2018年 小志. All rights reserved.
//

#import "GMMyClassCell.h"
@interface GMMyClassCell()

@property (weak, nonatomic) IBOutlet UIImageView *headImg;
@property (weak, nonatomic) IBOutlet UILabel *headTit;
@property (weak, nonatomic) IBOutlet UIButton *biaoqian;
@property (weak, nonatomic) IBOutlet UILabel *orgName;
@property (weak, nonatomic) IBOutlet UILabel *desLab;
@property (weak, nonatomic) IBOutlet UIImageView *stateImg;

@end
@implementation GMMyClassCell

- (void)awakeFromNib {
    [super awakeFromNib];
}

-(void)setModel:(GMMyclassModel *)model{
    _model = model;
    [self.headImg yy_setImageWithURL:[NSURL URLWithString:model.HeadUrl] placeholder:DefealtImg];
    self.headTit.text = model.Name;
    if ([model.ResTypeName isEqualToString:@"课程包"]) {
        self.biaoqian.layer.borderWidth =1.0;
        self.biaoqian.layer.borderColor =kRedColor.CGColor;
        [self.biaoqian setTitleColor:kRedColor forState:0];
        self.biaoqian.layer.cornerRadius=5;
    }else{
        self.biaoqian.layer.borderWidth =1.0;
        self.biaoqian.layer.borderColor =[UIColor colorWithHexString:@"FF7708"].CGColor;
        [self.biaoqian setTitleColor:[UIColor colorWithHexString:@"FF7708"] forState:0];
        self.biaoqian.layer.cornerRadius=5;
    }
    [self.biaoqian setTitle:[NSString stringWithFormat:@"  %@  ",model.ResTypeName] forState:UIControlStateNormal];
    self.orgName.text = model.FromName;
    
    self.stateImg.hidden = YES;
    if (model.NormalCode >0 && model.NormalCode <= 2) {
        self.stateImg.hidden = NO;
        self.stateImg.image =[UIImage imageNamed:@"exception-corner-red"];
    }else if (model.NormalCode == 3){
        self.stateImg.hidden = NO;
        self.stateImg.image =[UIImage imageNamed:@"over-corner-orange"];
    }

    if ([model.ResType isEqualToNumber:@(1)]) {
        /**视频*/
        NSString *perStr = [NSString stringWithFormat:@"%@%%",model.Percent];
        NSString *desStr = [NSString stringWithFormat:@"%@分钟  %@",model.TimeLen,perStr];
        self.desLab.attributedText = [NSMutableAttributedString String:desStr RangeString:perStr];
    }else if ([model.ResType isEqualToNumber:@(2)]){
        /**文档*/
        NSString *perStr = [NSString stringWithFormat:@"%@%%",model.Percent];
        NSString *desStr = [NSString stringWithFormat:@"%@页  %@",model.PageCount,perStr];
        self.desLab.attributedText = [NSMutableAttributedString String:desStr RangeString:perStr];
    }else if ([model.ResType isEqualToNumber:@(3)]){
        /**习题*/
        NSString *perStr = [NSString stringWithFormat:@"%@%%",model.Percent];
        NSString *desStr = [NSString stringWithFormat:@"%@题  %@",model.ExerCount,perStr];
        self.desLab.attributedText = [NSMutableAttributedString String:desStr RangeString:perStr];
    }else if ([model.ResType isEqualToNumber:@(4)]){
        /**试卷*/
        NSString *desStr = [NSString stringWithFormat:@"测试%@次  平均%@分",model.Count,model.Score];
        self.desLab.attributedText = [NSMutableAttributedString String:desStr RangeString:[NSString stringWithFormat:@"%@",model.Score]];
    }else if ([model.ResType isEqualToNumber:@(9)]){
        /**课程包*/
          self.desLab.text = [NSString stringWithFormat:@"%@资源",model.PageCount];
    }
}

@end
